package com.cqie.controller.user;


import com.cqie.dto.user.DoctorLoginDto;
import com.cqie.exception.SpecialException;
import com.cqie.service.IDoctorsLoginService;
import com.cqie.util.ResultTemplate;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 不吃海鲜
 * @since 2024-11-25
 */
@Tag(name = "医生登陆Controller", description = "描述：医生登陆接口")
@RestController
@RequestMapping({"/api/v1.0/doctorsLogin", "/api/v1/doctorsLogin"})
public class DoctorsLoginController {

    private final IDoctorsLoginService doctorsLoginService;

    public DoctorsLoginController(IDoctorsLoginService doctorsLoginService) {
        this.doctorsLoginService = doctorsLoginService;
    }


    @Operation(summary = "医生登陆注册")
    @PostMapping(value = "/registerDoctor")
    public ResultTemplate<Boolean> registerDoctor(@RequestBody DoctorLoginDto doctorLoginDto) throws SpecialException {
        return ResultTemplate.Success(doctorsLoginService.registerDoctor(doctorLoginDto));
    }

    @Operation(summary = "医生登陆")
    @PostMapping(value = "/doctorLogin")
    public ResultTemplate<String> doctorLogin(@RequestBody DoctorLoginDto doctorLoginDto) throws SpecialException {
        return ResultTemplate.Success(doctorsLoginService.doctorLogin(doctorLoginDto));
    }

    @Operation(summary = "医生退出登陆")
    @GetMapping(value = "/doctorLogout")
    public ResultTemplate<Boolean> doctorLogout(String doctorToken) throws SpecialException {
        return ResultTemplate.Success(doctorsLoginService.doctorLogout(doctorToken));
    }

}
